package com.jifeng.api.crud.controller;

import com.jifeng.api.crud.entity.FeeConfigEntity;
import com.jifeng.api.crud.service.FeeConfigService;
import com.jifeng.api.utils.PageUtils;
import com.jifeng.api.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-09-17 21:36:32
 */
@RestController
@RequestMapping("/crud/fee")
public class FeeConfigController {
    @Autowired
    private FeeConfigService feeConfigService;

    /**
     * 修改基础费用信息
     */
    @PostMapping("/pc/config/upd")
    public R updateConfig(@RequestBody FeeConfigEntity feeConfig){
        R rs= feeConfigService.updateConfig(feeConfig);
        return rs;
    }

    /**
     * 修改入库接口
     */
    @PostMapping("/update")
    public R update(@RequestBody FeeConfigEntity feeConfig){
        R rs= feeConfigService.myUpdateById(feeConfig);
        return rs;
    }

    /**
     * 获取收费策略信息
     */
    @GetMapping("/config/get")
    public R getFeeConfig(){
       R rs= feeConfigService.getFeeConfig();
       return rs;
    }
    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = feeConfigService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		FeeConfigEntity feeConfig = feeConfigService.getById(id);

        return R.ok().put("feeConfig", feeConfig);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody FeeConfigEntity feeConfig){
		feeConfigService.save(feeConfig);

        return R.ok();
    }



    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		feeConfigService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
